package com.bank.dao;

import com.bank.entity.BankOprecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class OprecordDao {
    @Autowired
    JdbcTemplate jdbcTemplate;
    public BankOprecord queryByAid(long aid) {
        String sql = "select * from bank_oprecord where aid = ?";
        return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<BankOprecord>(BankOprecord.class),aid);
    }
    public int insert(BankOprecord oprecord) {
        String sql=" insert into bank_oprecord values(default,?,?,?,now(),?) ";
        return jdbcTemplate.update(sql, oprecord.getAid(),
                oprecord.getOpmoney(),
                oprecord.getCharge(),
                oprecord.getRemark());
    }
}
